package com.keqing.tomato.state;

import static android.widget.Toast.LENGTH_SHORT;
import static com.keqing.tomato.util.SoundUtil.palySound;

import android.widget.Toast;

public class RestingState extends State {
    @Override
    public void initPage() {
        setPageContent(null, null, null, fragment.restingBtn);
        fragment.timerService.startTimer(fragment.mySetting.getRestTime(), fragment.timeModeBtn.isChecked());
    }

    @Override
    public void clickBeginFocus() {
        //no this event
    }

    @Override
    public void clickBeginRest() {
        //no this event
    }

    @Override
    public void doTimerFinish() {
        fragment.timerFinishHandler.post(new Runnable() {
            @Override
            public void run() {
                fragment.changeState(new BeginFocusState());
                fragment.timerFinishHandler.sendEmptyMessageDelayed(finish_rest,1000);
                //振动
                playVibration();
                //响铃
                palySound(fragment.mySetting.getRestSoundPath(), fragment.activity);
            }
        });
    }

    @Override
    public void clickReset() {
        Toast.makeText(fragment.activity, "请在休息结束后重置", LENGTH_SHORT).show();
    }

    @Override
    public void clickTimeMode() {
        fragment.timeModeBtn.setChecked(!fragment.timeModeBtn.isChecked());
        Toast.makeText(fragment.activity, "请在休息结束后设置", LENGTH_SHORT).show();
    }
}
